const amqp=require('amqp-connection-manager');
const { createChannel } = require('../../util/rabbitmq');
const connect=require('../../util/rabbitmq');
class sendStream{
    constructor(queueName){
       this.queueName=queueName;
       this.channel=connect.createChannel({json:true});
       
    }
    async createChannel(){
       const self=this;
       await  this.channel.addSetup(function(channel){
            //返回绑定队列的channel 
            console.log('创建channel',self.queueName);
            return Promise.all([channel.assertQueue(self.queueName,{durable:false})]) ;
        });
    }
       
    sendMessage(msg){
        schedule.
        console.log('发送数据到数据{}',msg);
        this.channel.sendToQueue(this.queueName,msg).catch(function(err){
            console.log("Message was rejected:", err.stack);
            this.channel.close();
            connect.close();
        });
    }
}
module.exports=sendStream;